package com.sub.project.info.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sub.framework.redis.RedisCache;
import com.sub.project.info.domain.School;
import com.sub.project.info.mapper.TbSchoolMapper;
import com.sub.project.info.service.ITbSchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TbSchoolServiceImpl extends ServiceImpl<TbSchoolMapper,School> implements ITbSchoolService {

    @Autowired
    TbSchoolMapper schoolMapper;

    @Autowired
    private RedisCache redisCache;

    @Override
    public List<String> findName() {
        /** 先从缓存中查询学校信息 */
        List<String> schoolName  =  redisCache.getCacheObject("school:schoolList");
        /** 查询数据存入redis */
            if (schoolName == null){
                 schoolName = schoolMapper.selectName();
                 redisCache.setCacheObject("school:schoolList", schoolName );
            }
        return schoolName;
    }
}
